﻿@model planerka.DataAccess.Models.user

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
@{bool rightsEdit  = Model.rightsEdit;
  
  //object htmlReadOnlyAttrib = new {};
  //object htmlDisabledAttrib = new { };
  string readonlyClass = "";
  if (!rightsEdit)
  {
    //htmlReadOnlyAttrib = new { @readonly = "readonly"};
    //htmlDisabledAttrib = new { @disabled = "disabled" };
    readonlyClass = "readonly";
  }
}
<span class="resultMessage">@Html.Raw(ViewData["resultMessage"] != null ? ("<span>" + ViewData["resultMessage"] + "</span>") : "")</span> 
@using (Html.BeginForm("userDetails", "tm", FormMethod.Post, new { enctype = "multipart/form-data", name = "editItemForm", id = "editItemForm" }))
{

   <div class="editItem @readonlyClass">

   <h2 style="float: left;">@ViewData["caption"]</h2>

   @if (rightsEdit)
   {
    <input type="submit" value="Сохранить" class="save" />
   }
   
    <div class="clear"></div>

    @Html.ValidationSummary(true)
    <fieldset class="fieldsetEdit userEdit">
        
        @*@Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.UserId)*@

        <input id="ID" type="hidden" name="ID" value="@Model.ID" />
        <input id="UserId" type="hidden" name="UserId" value="@Model.UserId" />

        
        <div class="editor-label">
            Фамилия
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.surName,
                rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.surName)
        </div>

        <div class="editor-label">
            Имя
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.firstName, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.firstName)
        </div>

        <div class="editor-label">
            Отчество
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.middleName, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.middleName)
        </div>

        <div class="editor-label">
            Телефон
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.phone, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.phone)
        </div>

        <div class="editor-label">
            Электронная почта (email)
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.email, 
                !Model.isEmailApproved ? (object)new { } : (object)new { @readonly = "readonly", style=" background-color: #ebebeb;" })

            @Html.ValidationMessageFor(model => model.email)
        </div>

        <div class="editor-label">
            Сайт
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.http, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.http)
        </div>

        <div class="editor-label">
            Skype
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.skype, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.skype)
        </div>

        <div class="editor-label">
            ICQ
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.ICQ, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.ICQ)
        </div>

       
        <div class="editor-field">
        <br />
            <label>
            @Html.CheckBoxFor(model => model.isCustomer, rightsEdit ? (object)new { } : (object)new { @disabled = "disabled" })
            Заказчик
            </label>
            &nbsp;&nbsp;&nbsp;
            <label>
            @Html.CheckBoxFor(model => model.isPerformer, rightsEdit ? (object)new { } : (object)new { @disabled = "disabled" })
            Исполнитель
            </label>
        </div>

        <div class="editor-field">
            
        </div>

        
    </fieldset>
    <fieldset class="fieldsetEdit userEdit">
        <div class="editor-label">
            Описание
        </div>
        <div class="editor-field">
            @Html.TextAreaFor(model => model.aboutMe, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.aboutMe)
        </div>

        <div class="editor-label">
            Компания
        </div>
        <div class="editor-field">
            @Html.TextBoxFor(model => model.companyName, rightsEdit ? (object)new { } : (object)new { @readonly = "readonly" })
            @Html.ValidationMessageFor(model => model.companyName)
        </div>

        <div class="editor-label">
            Фотография
        </div>

        <input id="photoNail" type="file" name="photoNail" />

        <div class="editor-field" style="text-align: center;">
        
        @if (Model.photoFileString != "")
        {
        
            <a href="@Url.Content("~" + Model.photoFileString)" title="Фотография" class='highslide'
                onclick="return hs.expand(this)">
                <img alt="Фотография" src="@Url.Content("~" + Model.photoNailFileString)"  />
                </a>
        }
        else
        {
            <img alt="фотография" src="@Url.Content("~" + Model.photoNailFileString)" class="photoNail" />
        }
        </div>

    </fieldset>

    <div class="clear"></div>
    </div>
}




